package cn.stylefeng.guns.modular.business.frequency.ordercontract.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.business.frequency.ordercontract.service.OrderContractService;
import cn.stylefeng.guns.modular.business.frequency.ordercontract.model.param.OrderContractParam;

import javax.annotation.Resource;

/**
 * 订单合同 控制器
 *
 * @author: yujie
 * @date: 2023/05/09 17:16
 */
@RestController
public class OrderContractController {

    @Resource
    private OrderContractService orderContractService;

    /**
     * 分页查询订单合同
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @GetMapping("/orderContract/page")
    @BusinessLog(title = "订单合同_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(OrderContractParam orderContractParam) {
        return new SuccessResponseData(orderContractService.page(orderContractParam));
    }

    /**
     * 获取全部订单合同
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @GetMapping("/orderContract/list")
    @BusinessLog(title = "订单合同_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(OrderContractParam orderContractParam) {
        return new SuccessResponseData(orderContractService.list(orderContractParam));
    }

    /**
     * 查看详情订单合同
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @GetMapping("/orderContract/detail")
    @BusinessLog(title = "订单合同_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(OrderContractParam.detail.class) OrderContractParam orderContractParam) {
        return new SuccessResponseData(orderContractService.detail(orderContractParam));
    }

    /**
     * 添加订单合同
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @PostMapping("/orderContract/add")
    @BusinessLog(title = "订单合同_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(OrderContractParam.add.class) OrderContractParam orderContractParam) {
        orderContractService.add(orderContractParam);
        return new SuccessResponseData();
    }

    /**
     * 删除订单合同
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @PostMapping("/orderContract/delete")
    @BusinessLog(title = "订单合同_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(OrderContractParam.delete.class) OrderContractParam orderContractParam) {
        orderContractService.delete(orderContractParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑订单合同
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @PostMapping("/orderContract/edit")
    @BusinessLog(title = "订单合同_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(OrderContractParam.edit.class) OrderContractParam orderContractParam) {
        orderContractService.edit(orderContractParam);
        return new SuccessResponseData();
    }


}
